<template>
  <n-card :bordered="false" class="proCard">
    <!-- <BasicForm @register="register" @submit="handleSubmit" @reset="handleReset">
      <template #chanSelect="{ model, field }">
        <n-select v-model:value="model[field]" :options="registChanArray"/>
      </template>
    </BasicForm> -->

    <BasicTable
      :columns="columns"
      :request="loadDataTable"
      :row-key="(row) => row.id"
      ref="actionRef"
      :actionColumn="actionColumn"
      @update:checked-row-keys="onCheckedRow"
      :scroll-x="2048"
      :paginate-single-page="false"
    >

      <template #toolbar>
        <n-button type="primary" @click="reloadTable">刷新数据</n-button>
      </template>
    </BasicTable>
  </n-card>
</template>

<script lang="ts" setup>
  import {computed, h, onMounted, reactive, ref, unref} from 'vue';
  import {useDialog, useMessage} from 'naive-ui';
  import {BasicTable, TableAction} from '@/components/Table';
  import {BasicForm, FormSchema, useForm} from '@/components/Form/index';
  import {getTableList} from '@/api/table/list';
  import {PlusOutlined} from '@vicons/antd';
  import {useRouter, useRoute} from 'vue-router';
  import {getAnchorDailyRecords} from "@/api/liveBroadcast/anchorDailyRecords";
  import {formatToDate} from "@/utils/dateUtil";
  import {comment} from "postcss";

  const route = useRoute();

  const columns = [
  {
    title: '日期',
    key: 'createTime'
    },
    {
    title: '主播名称',
    key: 'anchorName',
    width:200,
    render:(row)=>{
            return route.params.name
        }
    },
    {
    title: '渠道',
    key: 'chanId',
    width:200,
    render:(row)=>{
            return route.params.id
        }
    },
  {
    title: '注册',
    key: 'registNum'
  },
  {
    title: '首日付费金额',
    key: 'firstDayPayAmount'
  },
  {
    title: '首日付费人数',
    key: 'firstDayPayNum'
  },
  {
    title: '累计付费金额',
    key: 'totalPayAmount'
  },
  {
    title: '总付费人数',
    key: 'totalPayNum'
  }
 
];


  const registChanArray = ref([]);
  


  const router = useRouter();
  
  const formRef: any = ref(null);
  const message = useMessage();
  const dialog = useDialog();
  const actionRef = ref();

  const showModal = ref(false);
  const formBtnLoading = ref(false);
  const formParams = reactive({
    id: route.params.id
  });



  const [register, {}] = useForm({
    gridProps: {cols: '1 s:1 m:2 l:3 xl:4 2xl:4'},
    labelWidth: 80,
  });

  function addTable() {
    showModal.value = true;
  }

  const loadDataTable = async (res) => {
    const param = {...formParams, ...res};
    console.log(param);
    console.log(route.params);
    delete param.makeDate;
    return await getAnchorDailyRecords(param);
  };

  function onCheckedRow(rowKeys) {
    console.log(rowKeys);
  }

  function reloadTable() {
    actionRef.value.reload();
  }

  

  function handleSubmit(values: Recordable) {
    console.log("submit",values);
    let tempParams = unref(formParams);
    tempParams = Object.assign(tempParams, values);
    reloadTable();
  }

  function handleReset(values: Recordable) {
    console.log(values);
  }

</script>

<style lang="less" scoped></style>
